//
//  UserViewController.m
//  one·一个  tyw
//
//  Created by tyw on 15/8/20.
//  Copyright (c) 2015年 tyw. All rights reserved.
//

#import "UserViewController.h"
#import "DayNightLabel.h"
#import "DayNightManager.h"
#import "UserlLikeViewController.h"
#import "SettingViewController.h"
#import "AboutViewController.h"

@interface UserViewController ()

@end

@implementation UserViewController {
    UITableView* _tableView;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    
    self.navigationItem.rightBarButtonItem = nil;       //个人页面没有分享按钮
    
    
    [self _createTableView];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
}

- (void)_createTableView {
    _tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
    [self.view addSubview:_tableView];
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _tableView.backgroundColor = [UIColor clearColor];
    
    _tableView.delegate = self;
    _tableView.dataSource = self;
}

#pragma mark - tableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell* cell = [[UITableViewCell alloc] init];
    
    if (indexPath.row == 0) {       //个人
        //头像
        UIImageView* headImgView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 10, 30, 30)];
        headImgView.layer.cornerRadius = 15;
        headImgView.layer.masksToBounds = YES;
        headImgView.image = [UIImage imageNamed:@"1.jpg"];
        [cell.contentView addSubview:headImgView];
        
        //名字
        DayNightLabel* nameLabel = [[DayNightLabel alloc] initWithFrame:CGRectMake(70, 10, kWidth-100, 30)];
        nameLabel.text = @"阿狸";
        nameLabel.textAlignment = NSTextAlignmentLeft;
        nameLabel.font = [UIFont systemFontOfSize:18];
        [nameLabel loadLabelColor];
        [cell.contentView addSubview:nameLabel];
    } else if (indexPath.row == 1) {    //设置
        //设置图标
        UIImageView* headImgView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 10, 30, 30)];
        headImgView.image = [UIImage imageNamed:@"setting"];
        [cell.contentView addSubview:headImgView];
        //设置
        DayNightLabel* nameLabel = [[DayNightLabel alloc] initWithFrame:CGRectMake(70, 10, kWidth-100, 30)];
        nameLabel.text = @"设置";
        nameLabel.textAlignment = NSTextAlignmentLeft;
        nameLabel.font = [UIFont systemFontOfSize:18];
        [nameLabel loadLabelColor];
        [cell.contentView addSubview:nameLabel];
    } else {                            //关于
        //关于图标
        UIImageView* headImgView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 10, 30, 30)];
        headImgView.image = [UIImage imageNamed:@"copyright"];
        [cell.contentView addSubview:headImgView];
        
        //关于
        DayNightLabel* nameLabel = [[DayNightLabel alloc] initWithFrame:CGRectMake(70, 10, kWidth-100, 30)];
        nameLabel.text = @"关于";
        nameLabel.textAlignment = NSTextAlignmentLeft;
        nameLabel.font = [UIFont systemFontOfSize:18];
        [nameLabel loadLabelColor];
        [cell.contentView addSubview:nameLabel];
    }
    
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.backgroundColor = [UIColor clearColor];
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 50;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (indexPath.row == 0) {       //进入个人收藏页面
        UserlLikeViewController* userLikeVC = [[UserlLikeViewController alloc] init];
        [self.navigationController pushViewController:userLikeVC animated:YES];
    } else if (indexPath.row == 1) {        //设置界面
        SettingViewController* settingVC = [[SettingViewController alloc] init];
        [self.navigationController pushViewController:settingVC animated:YES];
    } else {                        //关于界面
        AboutViewController* aboutVC = [[AboutViewController alloc] init];
        [self.navigationController pushViewController:aboutVC animated:YES];
    }
}

@end
